package com.weirdor.wxchat.www.web;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.weirdor.wxchat.module.entity.QywxTexttemplate;
import com.weirdor.wxchat.module.service.IQywxTexttemplateService;
import com.weirdor.wxchat.support.utils.R;
import com.xiaoleilu.hutool.convert.Convert;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.nio.file.Files;
import java.util.Map;




/**
 * 文本模板
 * 
 * @author weirdor
 * @email 179946422@qq.com
 * @date 2017-12-01 17:31:47
 */
@RestController
@RequestMapping("/module/qywxtexttemplate")
public class QywxTexttemplateController {
	@Autowired
	private IQywxTexttemplateService qywxTexttemplateService;


	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("module:qywxtexttemplate:list")
	public R list(@RequestParam Map<String, Object> params){
		EntityWrapper<QywxTexttemplate> wrapper = new EntityWrapper<QywxTexttemplate>();
		Page<QywxTexttemplate> pageUtil=qywxTexttemplateService.selectPage(new Page<QywxTexttemplate>(Convert.toInt(params.get("page")),Convert.toInt(params.get("limit"))),wrapper);
		return R.ok().put("page", pageUtil);
	}

	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("module:qywxtexttemplate:info")
	public R info(@PathVariable("id") String id){
		QywxTexttemplate qywxNewstemplate = qywxTexttemplateService.selectById(id);

		return R.ok().put("qywxTexttemplate", qywxNewstemplate);
	}

	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("module:qywxtexttemplate:save")
	public R save(@RequestBody QywxTexttemplate qywxNewstemplate){
		qywxTexttemplateService.insert(qywxNewstemplate);

		return R.ok();
	}

	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("module:qywxtexttemplate:update")
	public R update(@RequestBody QywxTexttemplate qywxNewstemplate){
		qywxTexttemplateService.updateById(qywxNewstemplate);

		return R.ok();
	}

	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("module:qywxtexttemplate:delete")
	public R delete(@RequestBody String[] ids){
		EntityWrapper<QywxTexttemplate> entityWrapper=new EntityWrapper<>();
		entityWrapper.in("id",ids);
		qywxTexttemplateService.delete(entityWrapper);
		return R.ok();
	}

}
